package com.edgar;

import org.yaml.snakeyaml.Yaml;
import org.yaml.snakeyaml.constructor.SafeConstructor;

import javax.json.Json;
import javax.json.JsonObject;
import javax.json.JsonObjectBuilder;
import javax.json.JsonValue;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.Map;

/**
 * @author liqs
 * @version 1.0
 * @date 2021/5/6 9:52
 */
public class Main {

    public static void main(String[] args) throws FileNotFoundException {
        File file = new File("D:\\conf.yaml");
        FileInputStream inputStream = new FileInputStream(file);
        Yaml yaml = new Yaml(new SafeConstructor());
        Map<String, Object> map = yaml.load(inputStream);
        JsonObjectBuilder builder = Json.createObjectBuilder(map);
        JsonObject jsonConfig = builder.build();
        System.out.println(jsonConfig);
    }

}
